import React, { useState } from 'react'
import { useDispatch } from 'react-redux';
import axios from 'axios'
// 函数组件
const App: React.FC = () => {
  const [nickname, setNickname] = useState('');
  const dispatch = useDispatch()
  const submit = () => {
    // dispatch(() => {
      axios.post('/api/user/add', {
        nickname,
        id: new Date().getTime(),
        key: new Date().getTime(),
        avator: 'xxxx'
      }).then(() => {
        alert('提交成功')
      })
    // })
  }
  return (
    <div>
      <input type="text" value={nickname} onChange={(e) => setNickname(e.target.value)} />
      <button onClick={() => submit()}>提交</button>
    </div>
  )
}

export default App